home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_force_chainlight.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
9KB
|
333 lines
# Jedi Knight Cog Script
#
# FORCE_CLIGHTNING.COG
#
# FORCEPOWER Script - Force Chain Lightning
# Bin 39
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
template powerup local
int player local
int victim local
int potential local
int lightning_current local
int lightning_from local
int lightning_to local
int count local
flex cost=100.0 local
flex targetcost=5 local
flex targetcount=0 local
int rank local
flex mana local
flex dot local
flex maxDot local
flex dist local
flex minDist local
int type local
int retval=0 local
int dummy=0 local
template lightning=+force_clightn local
sound fireSound=ForceLightnin01.wav local
vector pos local
vector dir local
int sec local
int inbubble=0 local
message startup
message activated
message deactivated
message pulse
message timer
message newplayer
message killed
message deselected
message selected
message enterbubble
message exitbubble
end
# ========================================================================================
code
startup:
player = GetLocalPlayerThing();
inbubble = 0;
Return;
# ........................................................................................
activated:
if(inbubble) Return;
// Cannot use power if blinded
if(GetActorFlags(player) & 0x800) Return;
if(IsInvActivated(player, 39)) Return;
mana = GetInv(player, 14);
rank = GetInv(player, 39);
if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
{
victim = -1;
SetInvActivated(player, 39, 1);
SetPulse(0.33);
}
Return;
# ........................................................................................
pulse:
targetCount = targetCount + 1;
if(targetCount == 3)
{
if(GetInv(player, 64) != 1) ChangeInv(player, 14, -targetCost);
targetCount = 0;
}
victim = -1;
maxDot = 0;
// Search for all players and actors.
potential = FirstThingInView(player, 20 + 10 * rank, 5.0, 0x404);
while(potential != -1)
{
if(
HasLOS(player, potential) &&
(potential != player) &&
(VectorDist(GetThingPos(player), GetThingPos(potential)) <= 1.25) &&
!(GetThingFlags(potential) & 0x200) &&
!(GetActorFlags(potential) & 0x100) &&
!((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) &&
(jkGetBubbleDistance(potential) > 1.0)
)
{
dot = ThingViewDot(player, potential);
if(dot > maxDot)
{
victim = potential;
maxDot = dot;
}
}
potential = NextThingInView();
}
// If we have a victim...
if(victim != -1)
{
jkSetTargetColors(18, 19, 20);
jkSetTarget(victim);
}
else
{
jkEndTarget();
}
Return;
# ........................................................................................
deactivated:
if((victim == -1) || (GetThingHealth(player) <= 0) || inbubble)
{
call stop_power;
Return;
}
SetPulse(0);
jkEndTarget();
mana = GetInv(player, 14);
if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
{
if(HasLOS(player, victim)) // check that we still have a LOS on it...
{
if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
PlayMode(player, 24);
PlaySoundThing(fireSound, player, 1.0, -1, -1, 0x80);
// Send a "force disturbance"...
if(!IsMulti())
SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 39, 0, 0, 0);
SetBinWait(player, 39, 1.0);
lightning_from = player;
lightning_to = victim;
call throw_lightning;
lightning_current = victim;
for(count = 2; count <= rank; count = count + 1)
{
call get_next_target;
if(victim != -1)
{
lightning_from = lightning_current;
lightning_to = victim;
call throw_lightning;
lightning_current = victim;
}
else
{
// no one is in range, apply damage to the current victim
if(!IsMulti())
{
if((GetThingHealth(lightning_current) > 0) && (lightning_current != GetLocalPLayerThing()))
DamageThing(lightning_current, (rank - count + 1) * 10, 0x08, player);
}
else
{
if(!(GetThingFlags(lightning_current) & 0x200))
retval = SkillTarget(lightning_current, player, 39, (rank - count + 1) * 10);
}
SetInvActivated(player, 39, 0);
Return;
}
}
SetInvActivated(player, 39, 0);
Return;
}
}
SetInvActivated(player, 39, 0);
Return;
# ........................................................................................
timer:
Return;
# ........................................................................................
selected:
jkPrintUNIString(player, 39);
Return;
# ........................................................................................
deselected:
call stop_power;
Return;
# ........................................................................................
killed:
if(GetSenderRef() != player) Return;
newplayer:
call stop_power;
Return;
# ........................................................................................
enterbubble:
inbubble = 1;
call stop_power;
Return;
# ........................................................................................
exitbubble:
inbubble = 0;
Return;
# ........................................................................................
stop_power:
SetPulse(0);
SetInvActivated(player, 39, 0);
victim = -1;
jkEndTarget();
Return;
# ........................................................................................
get_next_target:
victim = -1;
minDist = 99999;
// There seem to be a bug when using values >= 180 degrees...
potential = FirstThingInView(lightning_current, 179, 5.0, 0x404);
while(potential != -1)
{
dist = VectorDist(GetThingPos(lightning_current), GetThingPos(potential));
if(
HasLOS(lightning_current, potential) &&
(potential != lightning_current) &&
(potential != player) &&
(dist <= 1.25) &&
!(GetThingFlags(potential) & 0x200) &&
!(GetActorFlags(potential) & 0x100) &&
!((jkGetFlags(potential) & 0x20) && !IsInvActivated(lightning_current, 23)) &&
(jkGetBubbleDistance(potential) > 1.0)
)
{
if(dist < minDist)
{
victim = potential;
minDist = dist;
}
}
potential = NextThingInView();
}
Return;
# ........................................................................................
throw_lightning:
dir = VectorNorm(VectorSub(GetThingPos(lightning_to), GetThingPos(lightning_from)));
sec = GetThingSector(lightning_from);
pos = VectorAdd(GetThingPos(lightning_from), VectorScale(dir, 0.07));
// Did the offset take us out of the sector ?
// if so get the new sector...
if(!IsSphereInSector(pos, 0.0, sec))
sec = FindSectorAtPos(pos);
if(sec >= 0)
CreateThingAtPos(lightning, sec, pos, dir);
// Apply damage. The lightning bolt used doesn't do damage on itself...
if(!IsMulti())
{
if((GetThingHealth(lightning_to) > 0) && (lightning_to != GetLocalPLayerThing()))
DamageThing(lightning_to, 25, 0x08, player);
}
else
{
retval = SkillTarget(lightning_to, player, 39, 25);
}
Return;
end